package com.example.contentprovider.contentProvider;

import android.content.ContentProvider;
import android.content.ContentValues;
import android.content.UriMatcher;
import android.database.Cursor;
import android.net.Uri;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

public class PeopleProvider extends ContentProvider {
    //URI的授权者名称
    public static final String AUTHORITY = "com.example.contentprovider";
    //单条数据的数据路径
    public static final String PATH_SINGLE = "people/#";//#可以代表任何数字
    //多条数据的数据路径
    public static final String PATH_MULTIPLE = "people";
    //CONTENT_URI的字符串形式
    public static final String CONTENT_URI_STRING = "content://" + AUTHORITY + "/" + PATH_MULTIPLE;
    public static final Uri CONTENT_URI = Uri.parse(CONTENT_URI_STRING);
    //多条数据的返回代码
    private static final int MULTIPLE_PEOPLE = 1;
    //单条数据的返回代码
    private static final int SINGLE_PEOPLE = 2;
    public static final UriMatcher uriMatcher;
    static {
        //声明UriMatcher的匹配方式和返回代码
        //UriMatcher.NO_MATCH是URI无匹配时的返回代码
        uriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
        uriMatcher.addURI(AUTHORITY, PATH_SINGLE, MULTIPLE_PEOPLE);
        uriMatcher.addURI(AUTHORITY, PATH_MULTIPLE, SINGLE_PEOPLE);
    }

    @Override
    public boolean onCreate() {

        return false;
    }

    @Nullable
    @Override
    public Cursor query(@NonNull Uri uri, @Nullable String[] strings, @Nullable String s, @Nullable String[] strings1, @Nullable String s1) {
        return null;
    }

    @Nullable
    @Override
    public String getType(@NonNull Uri uri) {
        return null;
    }

    @Nullable
    @Override
    public Uri insert(@NonNull Uri uri, @Nullable ContentValues contentValues) {
        return null;
    }

    @Override
    public int delete(@NonNull Uri uri, @Nullable String s, @Nullable String[] strings) {
        return 0;
    }

    @Override
    public int update(@NonNull Uri uri, @Nullable ContentValues contentValues, @Nullable String s, @Nullable String[] strings) {
        return 0;
    }
}
